package com.wangxin.study8.singleton;

/**
 * @author jojo.wang
 * @title: Singleton
 * @projectName study8
 * @description: 双检锁单例模式
 * @date 2019/5/716:22
 */

public class DoubleCheckedLockingSingleton {
    private static volatile DoubleCheckedLockingSingleton singleton;
    private DoubleCheckedLockingSingleton(){}
    public static DoubleCheckedLockingSingleton getInstance(){
        if (singleton==null){
            synchronized (DoubleCheckedLockingSingleton.class){
                if (singleton==null){
                    singleton = new DoubleCheckedLockingSingleton();
                }
            }
        }
        return singleton;
    }
}
